{% extends  data.theme + "/_base.html" %}

{% import "bootstrap/wtf.html" as wtf %}

{% block title %} {{data.title}} {% endblock %}

{%- block head -%} 
{{ super() }}
{%- endblock -%}

{% set form = data.form %}

{%- block body -%}

<div class="col-md-12" >

{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ message }}
</div>
{% endfor %}

<a href="{{url_for('clips.tag_list')}}" class="btn btn-default">← Back</a>
<p>
{# basic horizontal form_type="inline" #}
{{ wtf.quick_form(form) }}

<p>
<div class="list-group">
	{% if data.tag.id>0 %}
	<a href="{{url_for('clips.tagurl_edit',tagid=data.tag.id)}}" class="list-group-item active">创建链接</a> 
{% for url in data.tag.urls %}
	<div href="#" class="list-group-item">
	<a href="{{url_for('clips.tagurl_edit',id=url.id)}}" class="btn btn-primary btn-xs">编辑</a> 
	<a href="#" post="{{url_for('clips.tagurl_delete',id=url.id)}}" class="btn btn-primary btn-xs pull-right urlremove">删除JSON</a> 
	<a href="{{url_for('clips.tagurl_remove',id=url.id)}}" class="btn btn-primary btn-xs pull-right urlremove">删除</a> 
		{{url.title}} - {{url.url}}
	</div>
{% endfor %}
	{% endif%}
</div>

</div>
{% endblock %}

-------------------------------------

{% block script %}
{{ super() }}
<script type="text/javascript">
$(function() {
//当前使用的自动form 没有使用 可以用拦截并再提交的形式使用
	//这种方式可避免网络不好或者刷新的重复提交
    $('#btn_save').on("click",function(){
        $("#btn_save").attr('disabled',true);
        var form= $("#itemform")[0];
	if(form){
	    //form.pwd2.value = md5(form.pwd2.value);
	    //form.action="{{ url_for('clips.item_edit') }}";
	    form.submit();
	}
        $("#btn_save").attr('disabled',false);
    });

	//或者就不用delete.json实现 直接用remove页面处理并flash一下
	//简单的标签属性绑定js的实现
	$('a[post]').on("click",function(){
		var url=$(this).attr("post");
		postJson(url,function(){
			location.reload();
		});
	})
});
</script>
{% endblock %}
